package com.qtjf.qtmoneyservice.view;

import android.content.Context;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;

import com.github.jdsjlzx.recyclerview.LRecyclerView;
import com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter;
import com.qtjf.qtmoneyservice.R;
import com.qtjf.qtmoneyservice.adapter.HuoDongRecyclerAdapter;
import com.qtjf.qtmoneyservice.adapter.XiTongRecyclerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/6/27 0027.
 */

public class HuoDongView {
    View mView;
    Context mContext;


    LRecyclerView homeRecycler;
    List<String> lists;
    HuoDongRecyclerAdapter adapter;
    LRecyclerViewAdapter lRecyclerViewAdapter;

    public HuoDongView(Context mContext) {
        this.mContext = mContext;
    }

    public View getView()
    {
        mView=View.inflate(mContext, R.layout.huodong_layout_view,null);
        initView();
        initData();
        initEvent();
        return mView;
    }

    private void initView() {
        homeRecycler= (LRecyclerView) mView.findViewById(R.id.recycler_view);
        homeRecycler.setPullRefreshEnabled(false);
    }

    private void initData() {
        lists = new ArrayList<String>();
        for (int i = 0; i < 5; i++) {
            lists.add("" + i);
        }

        if (lists != null && lists.size() > 0) {
            if (adapter == null) {
                adapter = new HuoDongRecyclerAdapter(lists, mContext);
                lRecyclerViewAdapter = new LRecyclerViewAdapter(adapter);
                homeRecycler.setAdapter(lRecyclerViewAdapter);
                homeRecycler.setLayoutManager(new StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL));
                //  Toast.makeText(getContext(),"1",Toast.LENGTH_SHORT).show();
            } else {
                lRecyclerViewAdapter.notifyDataSetChanged();
                // Toast.makeText(getContext(),"2",Toast.LENGTH_SHORT).show();
                homeRecycler.refreshComplete();
            }
        }
    }

    private void initEvent() {
    }
}
